# ======================================================
# 			UNIVERSIDADE FEDERAL DE PERNANMBUCO
#
# MAKEFILE FOR PARALLEL OIL RESERVOIR SIMULATOR PROJECT
# Author: 	R. Soares
# Created:	Dec-2007
# ======================================================


# flag for compilation
# ====================
# NOTE: if you intend to run this programm in parallel, -D_HAVE_PETSC_  and
# -DPARALLEL flags must be added to CXXFLAGS variable
#CXXFLAGS=
CXXFLAGS=-DPARALLEL -D_HAVE_PETSC -DMPICH_IGNORE_CXX_SEEK -g -w

PROJ_DIR=$(HOME)/Padmec/PreProcessors-Unified
APP_DIR=$(HOME)/applications

# compilers
# =========
#CXX=g++
CXX=mpicxx

# paths for headers
# =================
INCLUDES=-I$(APP_DIR)/FMDB-64bits/FMDB/FMDB/include \
	 -I$(APP_DIR)/FMDB-64bits/FMDB/SCOREC-model/include \
 	 -I$(APP_DIR)/FMDB-64bits/FMDB/SCOREC-util/include \
         -I$(APP_DIR)/autopack/include \
	 -I$(PROJ_DIR)/include \

# paths for libraries
# ===================
LIBS=-L$(APP_DIR)/FMDB-64bits/FMDB/SCOREC-model/lib/generic-mpich2 -lSCOREC-model-O \
     -L$(APP_DIR)/FMDB-64bits/FMDB/SCOREC-util/lib/generic-mpich2 -lSCOREC-util-O \
     -L$(APP_DIR)/FMDB-64bits/FMDB/FMDB/lib/generic-mpich2 -lFMDB-O \
     -L$(APP_DIR)/ParMetis-3.1/lib -lparmetis -lmetis \
     -L$(APP_DIR)/autopack/lib -lautopack-O \

# path for where the objects must be put
# ======================================
OBJ_DIR=$(PROJ_DIR)/debug

# paths for each program source part
# ==================================
SRC_DIR=$(PROJ_DIR)/src

# object that will be linked later and tranformed into the executable file
# ========================================================================
OBJECTS=$(OBJ_DIR)/main.o $(OBJ_DIR)/manager.o  $(OBJ_DIR)/pre-processor2D-new.o \
        $(OBJ_DIR)/pre-processor2D-old.o $(OBJ_DIR)/pre-processor3D-old.o \
        $(OBJ_DIR)/export-coefficients.o $(OBJ_DIR)/exception.o \
        $(OBJ_DIR)/simulatorParameters.o $(OBJ_DIR)/auxiliar.o \
        $(OBJ_DIR)/Calculate-Cij-parallel.o $(OBJ_DIR)/Calculate-Vi-parallel.o \
        $(OBJ_DIR)/agg2D.o $(OBJ_DIR)/aggCV.o $(OBJ_DIR)/aggAux.o $(OBJ_DIR)/aggSE.o \
        $(OBJ_DIR)/aggTest.o $(OBJ_DIR)/aggSC.o $(OBJ_DIR)/output-meshes.o

# how the executable will be named
# ================================
EXEC=ppUnified.exe

## top taget
all:	$(EXEC)
## Build executable
# ===========================================================
$(EXEC):	$(OBJECTS) # chkopts
	@echo "Linking objects..."
	-$(CXX) -o $(EXEC) $(OBJECTS) ${LIBS}
## Compile all sources
# ===========================================================
$(OBJ_DIR)/%.o:	$(SRC_DIR)/%.cpp
	@echo "Compiling... please wait."
	$(CXX) $(CXXFLAGS) $(INCLUDES)  -c $<
	@mv *.o $(OBJ_DIR)


# clean remove objects and executable
# Note: petsc, for some reason, complains about using the word 'clean'
# so the word 'limpa' is used instead
limpa:
	@rm -f $(OBJ_DIR)/*.o $(EXEC)
	@echo "Limpeza concluida"
